from race.Player import *
import logging.config
from wowThread.threadJob import *
from pynput.keyboard import Key

logging.config.fileConfig('./util/logging.conf')
log = logging.getLogger("example")

"""
    子类描述：
        1、武僧坦克类
"""


class DruidTank(Player):

    def on_keyboard_press_son_before_thread(self, key):
        log.debug("on_keyboard_press_son_before_thread 1:进入了函数")
        # 有些按键是直接终止别人的，继续自己的，有些不是这样的，因此要区别对待【排列组合，情况非常多】/【也要超级符合每个职业的操作习惯】
        if key in (
                Key.f1, Key.f2, Key.f3, Key.f4, Key.f5, Key.f6, Key.f7, Key.f8, Key.f9, Key.f10, Key.f11,
                Key.f12):
            pass
        elif key == Key.enter:
            pass
        elif key == Key.space:
            pass
        elif key == Key.alt_l:
            pass
        elif key == Key.ctrl_l:
            pass
        elif key == Key.caps_lock:
            pass
        elif key == Key.shift_l:
            pass
        elif key.char == 'a':
            # 不终止别人，后面让只允许一个线程执行的逻辑来顺序排
            # ★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|
            # 并行并发执行的折中方案【通过触发其他按键，这样的好处是线程池统一管理了】
            # self.kb.press('r')
            # self.kb.release('r')
            #
            # self.kb.press('b')
            # self.kb.release('b')
            pass
        elif key.char == 'z':
            pass
        elif key.char == 'q':
            pass
        elif key.char == 'w':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'r':
            # 终止掉别人
            # interruptAllByForce()
            pass
        elif key.char == 'g':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'x':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'v':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'h':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'c':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'e':
            pass
        elif key.char == 's':
            pass
        elif key.char == 'd':
            pass
        elif key.char == 'f':
            pass
        elif key.char == 'b':
            pass
        return

    # 执行父类的方法
    # @logAop
    def a(self):
        # 父类的方法先执行（或者后续看看是不是就直接用之类覆盖之后的方法）
        self.startScheduler1()  # 调用 CallBackScheduler1
        self.startScheduler2()  # 调用 CallBackScheduler2
        # self.startScheduler7()  # 调用 CallBackScheduler7 # 测试win32方式的画线，画矩形（内存监控）

        self.startTiggerHP100_90()
        self.startTiggerHP90_80()
        self.startTiggerHP80_70()
        self.startTiggerHP70_60()
        self.startTiggerHP60_50()
        self.startTiggerHP50_40()
        self.startTiggerHP40_30()
        return

    def CallBackHP100_90(self):
        while self.ui.stopLoop == False:
            # 铁鬃
            self.pubAvgColorTiggerKeyBuffMode(self.WA_SQUARE_ZFX_X4, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX,
                                              self.WABloodBarDeltaY,
                                              self.WA_SQUARE_ZFX_AvgColor,
                                              'r', 'small', '3', self.WAITINGSECOND, 4, self.ELSEKEY_f9 ,self.DEBUG_CLOSE)

            # 鬃毛倒立
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.90, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.GREEN, 'small', Key.f3,
                                                  self.WAITINGSECOND,
                                                  4, self.ELSEKEY_f9, self.DEBUG_CLOSE)
        return

    def CallBackHP90_80(self):
        while self.ui.stopLoop == False:


            # 树皮
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.80, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.GREEN, 'small', '6', self.WAITINGSECOND,
                                                  4, self.ELSEKEY_f9, self.DEBUG_CLOSE)

            # 夺魂咆哮
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.85, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.GREEN, 'small', '\\', self.WAITINGSECOND,
                                                  4, self.ELSEKEY_f9, self.DEBUG_CLOSE)


            # 明月普照(高优先级)
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.83, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.GREEN, 'small', Key.f10,
                                                  self.WAITINGSECOND,
                                                  10, self.ELSEKEY_f9, self.DEBUG_CLOSE)
        return

    def CallBackHP80_70(self):
        while self.ui.stopLoop == False:
            # 狂暴回复
            # self.pubAvgColorTiggerKeyAndStopClickTwice(self.WABloodBarX + self.WABloodBarWidth * 0.75, self.WABloodBarY,
            #                                            self.WABloodBarDeltaX,
            #                                            self.WABloodBarDeltaY, self.WABloodBarAvgColor, self.GREEN,
            #                                            'small',
            #                                            '0', self.WAITINGSECOND01, 6, self.WA_SQUARE_ZFX_X1,
            #                                            self.WA_SQUARE_ZFX,
            #                                            self.WABloodBarDeltaX,
            #                                            self.WABloodBarDeltaY, self.RED, 0, 'small', self.ELSEKEY_1)
            # 狂暴回复
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.71, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.GREEN, 'small', '0', self.WAITINGSECOND,
                                                  10, self.ELSEKEY_f9, self.DEBUG_CLOSE)
            # 乌索尔旋风
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.80, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.GREEN, 'small', Key.f5,
                                                  self.WAITINGSECOND,
                                                  4, self.ELSEKEY_f9, self.DEBUG_CLOSE)


        return

    def CallBackHP70_60(self):
        while self.ui.stopLoop == False:
            # 吸血 沉睡着之怒   万灵之召->温希尔
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.69, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.GREEN, 'small', Key.f12, self.WAITINGSECOND,
                                                  4, self.ELSEKEY_f9, self.DEBUG_CLOSE)

            # 饰品1
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.7, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.GREEN, 'small', 'o',
                                                  self.WAITINGSECOND, 4, self.ELSEKEY_f9, self.DEBUG_CLOSE)
            # 牛头人群晕
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.7, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.GREEN, 'small', Key.f11,
                                                  self.WAITINGSECOND, 4, self.ELSEKEY_f9, self.DEBUG_CLOSE)
        return

    def CallBackHP60_50(self):
        while self.ui.stopLoop == False:
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.50, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.GREEN, 'small', '0', self.WAITINGSECOND,
                                                  10, self.ELSEKEY_f9, self.DEBUG_CLOSE)

            # 生存本能
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.65, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.GREEN, 'small', '5', self.WAITINGSECOND,
                                                  2, self.ELSEKEY_f9, self.DEBUG_CLOSE)

            # 饰品
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.60, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.GREEN, 'small', 't', self.WAITINGSECOND,
                                                  2, self.ELSEKEY_f9, self.DEBUG_CLOSE)
            # 饰品
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.55, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.GREEN, 'small', '4', self.WAITINGSECOND,
                                                  2, self.ELSEKEY_f9, self.DEBUG_CLOSE)
        return

    def CallBackHP50_40(self):
        while self.ui.stopLoop == False:
            # not生存本能
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.50, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.GREEN, 'small', '7', self.WAITINGSECOND,
                                                  2, self.ELSEKEY_1, self.DEBUG_CLOSE)
            # # 补狂暴回复
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.45, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.GREEN, 'small', '0', self.WAITINGSECOND,
                                                  10, self.ELSEKEY_1, self.DEBUG_CLOSE)

            # 花钱买的坦克防止死掉药水加血
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.42, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.RED, 'small', 'i', self.WAITINGSECOND,
                                                  4, self.ELSEKEY_1, self.DEBUG_CLOSE)
        return

    def CallBackHP40_30(self):
        while self.ui.stopLoop == False:
            # # 补狂暴回复
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.40, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.RED, 'small', '0', self.WAITINGSECOND,
                                                  10, self.ELSEKEY_1, self.DEBUG_CLOSE)

            # 甘鬙 30%
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.35, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.RED, 'small', '4', self.WAITINGSECOND,
                                                  4, self.ELSEKEY_1, self.DEBUG_CLOSE)

            # 化身
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.35, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.RED, 'small', '7', self.WAITINGSECOND,
                                                  4, self.ELSEKEY_1, self.DEBUG_CLOSE)
        return

    def CallBackScheduler1(self):
        while self.ui.stopLoop == False:
            # 切换目标
            self.click(self.kb, Key.tab, 1)

            self.click(self.kb, '9', 2)
            # 打月火术（减少普照的CD时间）
            self.click(self.kb, Key.f9, 3)
            sleep(0.2)
            # 明月普照(高优先级)
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.83, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.RED, 'small', Key.f10,
                                                  self.WAITINGSECOND,
                                                  10, self.ELSEKEY_f9, self.DEBUG_CLOSE)
        return

    def CallBackScheduler2(self):
        while self.ui.stopLoop == False:

            # 痛击
            self.pubAvgColorTiggerKeyBuffMode(self.WA_SQUARE_ZFX_X3, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX,
                                              self.WABloodBarDeltaY,
                                              self.WA_SQUARE_ZFX_AvgColor,
                                              self.RED, 'small', '1', self.WAITINGSECOND, 4, '9' ,self.DEBUG_CLOSE)
            # 裂伤
            self.pubAvgColorTiggerKeyBuffMode(self.WA_SQUARE_ZFX_X4, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX,
                                              self.WABloodBarDeltaY,
                                              self.WA_SQUARE_ZFX_AvgColor,
                                              self.RED, 'small', '2', self.WAITINGSECOND, 4, '9' ,self.DEBUG_CLOSE)
            # 打月火术（减少普照的CD时间）
            # self.click(self.kb, Key.f9, 3)
            # 打月火术（减少普照的CD时间）
            self.pubAvgColorTiggerKeyBuffMode(self.WA_SQUARE_ZFX_X5, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX,
                                              self.WABloodBarDeltaY,
                                              self.WA_SQUARE_ZFX_AvgColor,
                                              self.RED, 'big', Key.f9, self.WAITINGSECOND, 4, '9' ,self.DEBUG_CLOSE)


        return

    def on_mouse_click_son_before_thread(self, x, y, button, pressed):
        # 在鼠标点击，终止和打断其他动作（有些职业需要，有些不需要）??????????
        pass
        return

    def mouseRightClick(self, x, y):
        log.debug('★圣骑士坦克，鼠标click-right，需要开始执行的内容★')
        return

    def w(self):
        for i in range(1, 3):
            self.click(self.kb, '7', 3)
            sleep(0.3)
        return

    def q(self):
        for i in range(1, 7):
            self.click(self.kb, 'p', 3)
            sleep(0.3)
        return

    def c(self):
        for i in range(1, 7):
            self.click(self.kb, 'k', 3)
            sleep(0.3)

    def x(self):
        for i in range(1, 7):
            self.click(self.kb, Key.f4, 3)
            sleep(0.2)

        # 打断后的继续
        self.click(self.kb, 'a', 1)
        return

    def mouseUp(self, x, y):
        for i in range(1, 6):
            self.click(self.kb, '7', 3)
            sleep(0.2)
        return

    def mouseDown(self, x, y):
        for i in range(1, 6):
            self.click(self.kb, 'l', 3)
            sleep(0.2)
        return


class HealDruid(Player):

    def mouseUp(self, x, y):
        # AOE 抬团血
        # sleep(1.1)
        # 美德道标必须出来
        # self.click(self.kb, '4', 2)

        while True:
            # self.pubAvgColorCDNumberDeductInBlock(814, 944, 15, 15, self.GREEN, 0, '4', 'b', 100)
            self.click(self.kb, '6', 8)
            sleep(0.3)
            self.click(self.kb, '2', 3)

    def mouseDown(self, x, y):
        # 单体抬血
        while True:
            self.click(self.kb, '2', 3)
            sleep(0.3)

    def a(self):
        self.click(self.kb, '1', 3)
        sleep(1)
        self.click(self.kb, '1', 3)
        sleep(1)
        self.click(self.kb, '4', 2)

    def mouseRightClick(self, x, y):
        # 53,250           -->966,836
        # 在某块区域的点击，才生效，否咋就是不生效的，应为在其他区域的点击，可能在做其他的动作。
        if x > 53 and x < 818 and y > 250 and y < 836:
            self.click(self.kb, '1', 3)
            sleep(1)
            self.click(self.kb, '1', 3)
            sleep(1)
            self.click(self.kb, '4', 2)
            print('生日:' + str(x) + ':' + str(y))
        return

    def on_mouse_scroll_son_before_thread(self, dx, dy):
        if dy < 0:
            # 滚轮向下
            self.interruptAllByForceMouseUpDown()  # 强制打断正在运行的循环
        elif dy > 0:
            # 滚轮向上
            self.interruptAllByForceMouseUpDown()  # 强制打断正在运行的循环
        return

    def space(self):
        # self.click(self.kb, Key.tab, 1)
        self.click(self.kb, ']', 3)
        return

    # def f(self):
    #     #self.click(self.kb, Key.tab, 1)
    #     self.click(self.kb, '8', 6)
    #     return

    def q(self):
        for i in range(1, 4):
            self.click(self.kb, '4', 6)
        return

    def parallel1(self):
        # 父类的方法先执行（或者后续看看是不是就直接用之类覆盖之后的方法）
        for i in range(1, 888888):
            sleep(0.2)
            self.click(self.kb, 'i', 3)
            sleep(0.2)
            self.click(self.kb, 'k', 3)
        return

    def parallelAlt2(self):
        # 父类的方法先执行（或者后续看看是不是就直接用之类覆盖之后的方法）
        for i in range(1, 888888):
            # sleep(0.01)
            # self.click(self.kb, 't', 3)
            # sleep(0.01)
            sleep(1)
            pass


if __name__ == '__main__':
    pass
